﻿@model EdexApiClient.Invoices

@{           
    var LOCATION_GUID = "";
    var LOCATION_NAME = "";
        
    if (!Model.LOCATION_GUID.Equals(null)) 
    {
        LOCATION_GUID = Model.LOCATION_GUID.ToString();
        LOCATION_NAME = Model.LOCATION.LOCATION_NAME;               
    }
}

<form name="INVOICES" class="form-horizontal well" method="post"> 
    <fieldset> 
        
        <input type="hidden" name="GUID_RECORD" value="@Model.GUID_RECORD" />
        <input type="hidden" name="COMPANY_GUID" value="@Model.COMPANY_GUID" />
        <input type="hidden" name="CUSTOMER_GUID" value="@Model.CUSTOMER_GUID" />
        <input type="hidden" name="LOCATION_GUID" value="@LOCATION_GUID" />
        <input type="hidden" name="DOC_ID" value="@Model.DOC_ID" />
        <input type="hidden" name="VERSION" value="@Model.VERSION" />

        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span4">
                    <div class="row-fluid">
                        <div class="control-group"> 
                            <label class="control-label" for="CUSTOMER_NAME">Получатель</label>
                            <div class="controls row-fluid">
                                <input type="text" class="input-large" name="CUSTOMER_NAME" value="@Model.CUSTOMER.COMPANY_NAME" placeholder="Компания получатель" readonly="readonly" />
                            </div> 
                        </div>                                         
                        
                        <div class="control-group"> 
                            <label class="control-label" for="LOCATION_NAME">Склад</label>
                            <div class="controls row-fluid">
                                <div class="input-append">
                                    <input type="text" class="input-medium" name="LOCATION_NAME" value="@LOCATION_NAME" placeholder="Склад получателя" readonly="readonly" />
                                    <a href="javascript:void(0);" class="btn" data-index="@Model.GUID_RECORD" data-action="setLocationMapping"><i class="icon-edit"></i></a>
                                </div> 
                            </div> 
                        </div>  
                    </div>                
                </div> 

                <div class="span3">
                    <div class="row-fluid">
                        <div class="control-group"> 
                            <label class="control-label" for="DOC_DATE">Дата</label>
                            <div class="controls">
                                <div id="dt1" class="input-append date" data-date="" data-date-format="dd.mm.yyyy">
                                    <input type="text" class="input-small" name="DOC_DATE" value="@Model.DOC_DATE.ToString("dd.MM.yyyy")" placeholder="дд.мм.гггг" readonly="readonly" />
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </div> 
                        </div> 
 
                        <div class="control-group"> 
                            <label class="control-label" for="DOC_NUMBER">№</label>
                            <div class="controls">
                                <input type="text" class="input-small" name="DOC_NUMBER" value="@Model.DOC_NUMBER" readonly="readonly" />
                            </div> 
                        </div> 
                    </div>                                                      
                </div>                   

                <div class="span3">
                    <div class="row-fluid">                           
                        <div class="control-group"> 
                            <label class="control-label" for="TOTAL_AMOUNT">Сумма</label>
                            <div class="controls">
                                <input type="text" class="input-small" name="TOTAL_AMOUNT" value="@Model.TOTAL_AMOUNT" readonly="readonly" />
                            </div>
                        </div> 

                        <div class="control-group"> 
                            <label class="control-label" for="TAX_AMOUNT">Налог</label>
                            <div class="controls">
                                <input type="text" class="input-small" name="TAX_AMOUNT" value="@Model.TAX_AMOUNT" readonly="readonly" />
                            </div>
                        </div>  
                    </div> 
                </div> 
                                                      
            </div>
        </div>

        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">   
                    <div class="control-group"> 
                        <label class="control-label" for="NOTE">Примечание</label>
                        <div class="controls">
                            <textarea class="span12" name="NOTE" readonly="readonly">@Model.NOTE</textarea>
                        </div>
                    </div> 
                </div>
            </div>
        </div>

</form>

<table data-name="INVOICE_LINE" class="table table-striped zebra-striped tablesorter">
    <thead>
        <tr>
            <th>№</th>
            <th>Товар</th>
            <th>Код товара</th>
            <th>Количество</th>
            <th>Цена</th>
            <th>Сумма</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var record in Model.LINES.OrderBy(r => r.ORDER_NUM)) {
        <tr data-index="@record.GUID_RECORD">
            <td>@record.ORDER_NUM</td>
            <td>@(record.ITEM != null ? record.ITEM.ITEM_NAME : String.Empty)</td>
            <td>@(record.ITEM != null ? record.ITEM.EXT_KEY : String.Empty)</td>
            <td>@record.QUANTITY</td>
            <td>@record.PRICE</td>
            <td>@record.TOTAL</td>
        </tr>
        }
    </tbody>
</table>
